*** ============================================================
** Replication file for:
** Making Peace or Preventing It? UN Peacekeeping, Terrorism, and Civil War Negotiations
** Authors: Kaisa Hinkkainen Elliot, Sara M. T. Polo & Liana Eustacia Reyes
** Journal: International Studies Quarterly
*** ============================================================


*** ============================================================
** Set working directory and load complete dataset

cd "/Users/Kaisa/Dropbox/PK Negotiations HPR/Data"

use "/Users/Kaisa/Dropbox/PK Negotiations HPR/Data/ISQ_replication.dta", clear

* Log file

log using "/Users/Kaisa/Dropbox/PK Negotiations HPR/Data/ISQ_logfile", replace

*** ============================================================

set more off
set scheme s1mono
set seed 123

tsset dyad_id startcount

** Generating matched sample

cem lagattacks2 lagrebstr2 lagter2 lagethno2 brd_deathbestest_pre bd_pre, treatment(pkodum2)

*** ============================================================
*** Main manuscript models ***
*** ============================================================

** Table 2 Regression models for the probability of negotiations

*M1
logit negotiations l.attacksumnew trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M2
logit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M3
logit negotiations l.attacksumnew trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M4
logit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M5
logit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], cluster(dyad_id)
*M6
logit negotiations c.l.ter_ratio##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)

** Table 3 Bivariate probit regression

biprobit (negotiations = c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory) (pkodum2 = csdummy l.attacksumnew rebel_strength_new maingroup explicit_rebel_support_new polity2 lnbd number_episode num_months_episode territory ethnowar groupnum lngdp), robust cluster(dyad_id)

*** ============================================================
*** Online appendix ***
*** ============================================================

*** Matched sample models ***

** Table 4

* Summary statistics

sutex negotiations  ///
 attacksumnew soft hard_new ter_ratio trooplag1000 rebel_strength_new thirdparty maingroup ///
 explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ///
  ethnowar groupnum lngdp territory t pkodum2 csdummy count_success lngosv brd_event brd_new ///
  cumneg pastneg t2 t3 ceasefire partialpa pkoduration splagter cumter2 ///
  weakreb rc_loot terrornew_d, minmax

** Table 5  Baseline and successful attack models

*M1  
logit negotiations l.soft trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], cluster(dyad_id)
*M2
logit negotiations l.ter_ratio trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M3
logit negotiations l.count_success trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M4
logit negotiations c.l.count_success##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], cluster(dyad_id)

** Table 6 Alternative violence regressions

*M1
logit negotiations c.l.brd_event##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M2
logit negotiations c.l.brd_new##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M3
logit negotiations c.l.lnosv##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd number_episode num_months_episode ethnowar groupnum lngdp l.attacksumnew t territory [iweight=cem_weights], clust(dyad_id)
*M4
logit negotiations c.l.lngosv##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd number_episode num_months_episode ethnowar groupnum lngdp l.attacksumnew t territory [iweight=cem_weights], clust(dyad_id)
*M5
logit negotiations c.l.nkill##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)

** Table 7  Effect of UN troops on terrorism

*M1
logit terrornew_d c.trooplag1000 rebel_strength_new maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp pastneg territory, clust(dyad_id)
*M2
nbreg attacksumnew c.trooplag1000 rebel_strength_new maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp pastneg territory, clust(dyad_id)

** Table 8  Government one sided violence models

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv lngosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv lngosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv lngosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)

** Table 9  Cumulative and past negotiations regressions 

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 l.cumneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.cumneg l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory  [iweight=cem_weights], cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 l.cumneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory  [iweight=cem_weights], clust(dyad_id)
*M4
logit negotiations c.l.attacksumnew##c.trooplag1000 l.pastneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M5
logit negotiations c.l.soft##c.trooplag1000 l.pastneg l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], cluster(dyad_id)
*M6
logit negotiations c.l.ter_ratio##c.trooplag1000 l.pastneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)


** Table 10  Cubic polynomial regressions

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t t2 t3 territory [iweight=cem_weights], clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t t2 t3 territory  [iweight=cem_weights], cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t t2 t3 territory  [iweight=cem_weights], clust(dyad_id)

** Table 11  Ceasefires and partial peace agreements

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 l.ceasefire rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.ceasefire l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 l.ceasefire rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M4
logit negotiations c.l.attacksumnew##c.trooplag1000 l.partialpa rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M5
logit negotiations c.l.soft##c.trooplag1000 l.partialpa l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], cluster(dyad_id)
*M6
logit negotiations c.l.ter_ratio##c.trooplag1000 l.partialpa rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)

** Table 12 Regression models excluding partial peace agreements

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights] if partialpa !=1, clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory  [iweight=cem_weights] if partialpa !=1, cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory  [iweight=cem_weights] if partialpa !=1, clust(dyad_id)

** Table 13 PKO duration regressions

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 pkoduration rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 pkoduration l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 pkoduration rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)

** Table 14 Cumulative terrorism regressions

*M1
logit negotiations c.l.cumter2##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t t2 t3 territory [iweight=cem_weights], clust(dyad_id)
*M2
logit negotiations c.l.cumter2##c.trooplag1000 l.cumneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)
*M3
logit negotiations c.l.cumter2##c.trooplag1000 l.pastneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)

** Table 15 Spatial lag of terrorism

logit negotiations c.l.attacksumnew##c.trooplag1000 l.splagter rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)

** Table 16 Weak rebel sub-sample regressions

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights] if weakreb==1, clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory  [iweight=cem_weights] if weakreb==1, cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory  [iweight=cem_weights] if weakreb==1, clust(dyad_id)

** Table 17 Bivariate probit regression with additional variables

biprobit (negotiations = c.l.attacksumnew##c.trooplag1000 rc_loot rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t pkoduration territory) (pkodum2 = csdummy l.attacksumnew rc_loot rebel_strength_new maingroup explicit_rebel_support_new polity2 lnbd number_episode num_months_episode territory ethnowar groupnum lngdp), robust cluster(dyad_id)

*** ============================================================

*** Appendix full sample models ***

** Table 18 Baseline and successful attack models

*M1
logit negotiations l.soft trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, cluster(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, cluster(dyad_id)
*M3
logit negotiations l.ter_ratio trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M4
logit negotiations c.l.ter_ratio##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M5
logit negotiations l.count_success trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M6
logit negotiations c.l.count_success##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, cluster(dyad_id)

** Table 19 Alternative violence regressions

*M1
logit negotiations c.l.brd_event##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M2
logit negotiations c.l.brd_new##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M3
* One sided violence by rebels vs. terrorism
logit negotiations c.l.lnosv##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd number_episode num_months_episode ethnowar groupnum lngdp l.attacksumnew t territory, clust(dyad_id)
*M4
logit negotiations c.l.lngosv##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd number_episode num_months_episode ethnowar groupnum lngdp l.attacksumnew t territory, clust(dyad_id)
*M5
logit negotiations c.l.nkill##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)

** Table 20 Government one sided violence models

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv lngosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv lngosv number_episode num_months_episode ethnowar groupnum lngdp t territory, cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv lngosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)

** Table 21 Cumulative and past negotiations regressions

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 l.cumneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.cumneg l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 l.cumneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M4
logit negotiations c.l.attacksumnew##c.trooplag1000 l.pastneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M5
logit negotiations c.l.soft##c.trooplag1000 l.pastneg l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, cluster(dyad_id)
*M6
logit negotiations c.l.ter_ratio##c.trooplag1000 l.pastneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)

** Table 22 Cubic polynomial regressions

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t t2 t3 territory, clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t t2 t3 territory, cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t t2 t3 territory, clust(dyad_id)

** Table 23 Ceasefires and partial peace agreements

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 l.ceasefire rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.ceasefire l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 l.ceasefire rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M4
logit negotiations c.l.attacksumnew##c.trooplag1000 l.partialpa rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M5
logit negotiations c.l.soft##c.trooplag1000 l.partialpa l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, cluster(dyad_id)
*M6
logit negotiations c.l.ter_ratio##c.trooplag1000 l.partialpa rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)

** Table 24 Regression models excluding partial peace agreements

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory if partialpa !=1, clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory if partialpa !=1, cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory if partialpa !=1, clust(dyad_id)

** Table 25 PKO duration regressions

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 pkoduration rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 pkoduration l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 pkoduration rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)

** Table 26 Cumulative terrorism regressions

*M1
logit negotiations c.l.cumter2##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t t2 t3 territory, clust(dyad_id)
*M2
logit negotiations c.l.cumter2##c.trooplag1000 l.cumneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)
*M3
logit negotiations c.l.cumter2##c.trooplag1000 l.pastneg rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)

** Table 27 Spatial lag of terrorism

logit negotiations c.l.attacksumnew##c.trooplag1000 l.splagter rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, clust(dyad_id)

** Table 28 Weak rebel sub-sample regressions

*M1
logit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory if weakreb==1, clust(dyad_id)
*M2
logit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory if weakreb==1, cluster(dyad_id)
*M3
logit negotiations c.l.ter_ratio##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory if weakreb==1, clust(dyad_id)

** Table 29 Mixed effects regressions

*M1
xtmelogit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, || dyad_id:
*M2
xtmelogit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, || dyad_id:
*M3
xtmelogit negotiations c.l.ter_ratio##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory, || dyad_id:

*** ============================================================

*** Figures ***

** Figure 2 Marginal effects of attacks against non-official targets and UN troops

* install grstyle then run the following code
grstyle init
grstyle set plain, horizontal grid dotted

logit negotiations c.l.attacksumnew##c.trooplag1000 rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], clust(dyad_id)

margins, at(trooplag1000=(0 (0.1) 6) l.attacksumnew=(0 4)) atmeans l(83.5)
marginsplot, recastci(rarea) xlabel(0(1)6, grid) ylabel(0(0.2)0.8, grid) 

** Figure 3 Marginal effects of attacks against soft targets and UN troops

logit negotiations c.l.soft##c.trooplag1000 l.hard_new rebel_strength_new thirdparty maingroup explicit_rebel_support_new polity2 lnbd lnosv number_episode num_months_episode ethnowar groupnum lngdp t territory [iweight=cem_weights], cluster(dyad_id)

margins, at(trooplag1000=(0 (0.1) 6) l.soft=(0 4)) atmeans l(83.5)
marginsplot, recastci(rarea) xlabel(0(1)6, grid) ylabel(0(0.2)0.8, grid)

** Figure 1 & Table 1:

use "/Users/Kaisa/Dropbox/PK Negotiations HPR/Data/ISQ_replication.dta", clear
grstyle set plain, nogrid
rename v39 groupname
egen troopavg = mean(trooplag100) if trooplag1000 >0, by(dyad_id groupname)
collapse (sum) attacksum negotiations trooplag1000 (max) troopavg cem_weights, by(dyad_id groupname)
gen ter_b = 0
replace ter_b = 1 if attacksum > 0
gen pko_b = 0
replace pko_b = 1 if trooplag1000> 0
gen neg_b = 0
replace neg_b = 1 if negotiations >= 1

*Table 1
tab ter_b neg_b if pko_b == 1

tab ter_b neg_b if pko_b == 0
tab ter_b neg_b if pko_b == 1, column
tab ter_b neg_b if pko_b == 0, column

* How much terrorism in dyads with PKOs?
egen sumt = sum(attacksum), by( pko_b)
tab sumt
* 431 attacks in total across all dyads with PKO and 957 total attacks in dyads without PKO

ge lnattack = log(attacksum +1)
*use log scale for visual purposes
gen troopavg1 = troopavg*1000
replace troopavg1 =0 if troopavg1 ==.
gen lntroop = log(troopavg1 +1)
*use log scale for visual purposes

* Figure 1
twoway scatter lnattack lntroop if negotiations==0 & lntroop > 0, msymbol(S) ///
|| scatter lnattack lntroop if negotiations>0 & lntroop > 0, msymbol(O)

** Figure 4 Mali

/*

import delimited "globalterrorismdb_0718dist.csv"
keep if gname == "Azawad National Liberation Movement (MNLA)" | gname == "Arab Movement of Azawad (MAA)" | gname == "Coordination of Azawad Movements (CMA)" | gname2 == "Azawad National Liberation Movement (MNLA)" | gname3 == "Azawad National Liberation Movement (MNLA)"
gen attack = 1
collapse (sum) attack, by(imonth iyear)
sort iyear imonth

generate double newdate = ym(iyear, imonth)

format %tm newdate

tsset newdate
tsline(attack)

display monthly("2013m4","YM")

twoway (bar attack newdate, sort), xline(639)
di monthly("2015m6","YM")

twoway (bar attack newdate, sort), xline(639 665)

drop if iyear == 2017 

*/

capture log close
